#ifndef __IASSISTGEN2_UIEVENT_H
#define __IASSISTGEN2_UIEVENT_H

#include "UIModuleDef.h"
#include <string>
#include <list>

#pragma once

class UIEvent
{
public:
	UIEvent(void);
	~UIEvent(void);
	void deserializeJson(std::string jsonString);
	std::string serializeJson(void);
	void copyTo(UIEvent* event);

	inline void setSender(UIModuleType type)					{	m_sender	= type;		}
	inline void setReciever(UIModuleType type)					{	m_reciever	= type;		}
	inline void setSessionID(int id)							{	m_sessionID	= id;		}
	inline void setPairID(int id)								{	m_pairID	= id;		}
	inline void setType(std::string type)						{	m_type		= type;		}
	inline void setValue(std::string value)						{	m_value		= value;	}
	inline void setTimeStamp(long timeStamp)					{	m_timeStamp	= timeStamp;}
	//the data is not auto released by UIEvent
	inline void setBinaryData(unsigned char* data, int length)	{	m_binaryData = data; m_dataLength = length;	}

	inline UIModuleType getSender()						{	return m_sender;		}
	inline UIModuleType getReciever()					{	return m_reciever;		}
	inline int getSessionID()							{	return m_sessionID;		}
	inline int getPairID()								{	return m_pairID;		}
	inline long getTimeStamp()							{	return m_timeStamp;		}
	inline std::string getType()						{	return m_type;			}
	inline std::string getValue()						{	return m_value;			}
	inline unsigned char* getBinaryData(int& length)	{	length = m_dataLength; return m_binaryData;	}
	inline int getDataLength()							{	return m_dataLength;	}

	inline void deleteData()							{	if (m_binaryData != NULL) delete[] m_binaryData;	}

protected:
	UIModuleType m_sender, m_reciever;
	int m_sessionID;
	int m_pairID;
	long m_timeStamp;
	std::string m_type;
	std::string m_value;
	//the data is not auto released by UIEvent
	unsigned char* m_binaryData;
	int m_dataLength;

friend class UIEventRouter;
friend class UIModule;
};

#endif